package com.annet.token.controller;

import com.alibaba.fastjson.JSONObject;
import com.annet.token.dto.ResponseDTO;
import com.annet.token.model.ServerSetting;
import com.annet.token.service.ServerSettingServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Copyright © 2016 深圳安泰创新科技股份有限公司 版权所有 All Right Reserved
 *
 * @author: Dingjb
 * 包名：com.annet.token.controller
 * 时间：2021/1/4 10:32
 * 说明： token授权
 */
@RestController
@RequestMapping("/auth")
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class TokenController {

    private final ServerSettingServiceImpl serverSettingService;

    @PostMapping("/generateToken")
    public ResponseDTO generateToken(@RequestBody JSONObject json){
        return ResponseDTO.onSuccess(serverSettingService.generateToken(json));
    }

    @PostMapping("/config/generateToken")
    public ResponseDTO generateTokenByConfig(@RequestBody JSONObject json){
        return ResponseDTO.onSuccess(serverSettingService.generateTokenByConfig(json));
    }

}
